<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Chat Rooms</title>
    <!-- 引入Bootstrap样式文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css">
</head>
<body>
    <div class="container py-5">
        <h4 class="mb-4">你想进入哪个聊天室？请输入名字（注意，房间名只允许英文。）</h4>
        <div class="mb-4">
            <input id="room-name-input" type="text" size="100" class="form-control" value="HUAT">
        </div>
        <div>
            <input id="room-name-submit" type="button" value="进入聊天" class="btn btn-primary">
        </div>
    </div>

    <script>
        document.querySelector('#room-name-input').focus();
        document.querySelector('#room-name-input').onkeyup = function(e) {
            if (e.keyCode === 13) {  // enter, return
                document.querySelector('#room-name-submit').click();
            }
        };

        document.querySelector('#room-name-submit').onclick = function(e) {
            var roomName = document.querySelector('#room-name-input').value;
            window.location.pathname = '/chat/' + roomName + '/';
        };
    </script>

    <!-- 引入Bootstrap的JavaScript文件 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>